# This is Py-GenshinImpact Launcher script
import winreg


pth = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\原神"
name = "InstallPath"


def autoGet():
    try:
        # 打开注册表，原神！
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, pth)

        # 读取安装路径
        value, reg_type = winreg.QueryValueEx(key, name)

        print("Key value: ", value)
        winreg.CloseKey(key)
        return value
    except WindowsError as e:
        print("错误: ", e)
        return "Error"


v = autoGet()
a = open('path.config','w')
a.write(v)
a.close()